package com.acg.auth.service.impl;

import com.acg.auth.pojo.News;
import com.acg.auth.mapper.NewsMapper;
import com.acg.auth.service.NewsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.PortResolverImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author acg
 * @since 2025-08-08
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {

    @Autowired
    private NewsMapper newsMapper;

    @Override
    public List<News> getByTypeId(Long id) {
        // 构造查询条件 typeId = 传进来的 id
        LambdaQueryWrapper<News> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(News::getTypeId,id);
        wrapper.eq(News::getStatus,"已发布");
        //查询并将结果返回
        return this.list(wrapper);
    }

    @Override
    public List<News> selectByUserId(Long id) {
//        LambdaQueryWrapper<News> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(News::getIsDeleted,0);
        return newsMapper.selectNewsByUserId(id);
    }
}
